import request from "@/utils/request";

// 用户端API接口

// 首页内容相关接口
export const homepageApi = {
  // 获取轮播图数据
  getCarouselData() {
    return request.get("/api/homepage/carousel");
  },

  // 获取展会亮点数据
  getHighlightsData() {
    return request.get("/api/homepage/highlights");
  },

  // 获取展区数据
  getZonesData() {
    return request.get("/api/homepage/zones");
  },

  // 获取活动数据
  getEventsData() {
    return request.get("/api/homepage/events");
  },

  // 获取新闻数据
  getNewsData() {
    return request.get("/api/homepage/news");
  },

  // 获取客户见证数据
  getTestimonialsData() {
    return request.get("/api/homepage/testimonials");
  },

  // 获取合作伙伴数据
  getPartnersData() {
    return request.get("/api/homepage/partners");
  },

  // 获取图片画廊数据
  getGalleryData() {
    return request.get("/api/homepage/gallery");
  },

  // 获取展会统计数据
  getStatisticsData() {
    return request.get("/api/homepage/statistics");
  },

  // 获取展会主视觉数据
  getMainVisualData() {
    return request.get("/api/homepage/main-visual");
  },

  // 获取展会概览统计数据
  getOverviewStats() {
    return request.get("/api/homepage/overview-stats");
  },

  // 获取视频宣传片数据
  getVideoData() {
    return request.get("/api/homepage/video");
  },

  // 获取展会现场直播数据
  getLiveData() {
    return request.get("/api/homepage/live");
  },

  // 获取参展企业数据
  getExhibitorData() {
    return request.get("/api/homepage/exhibitor");
  },

  // 获取展品商城轮播图
  getProductBannerData() {
    return request.get("api/homepage/content/carousel_exhibitors_shop");
  },
};

// 活动相关接口
export const activityApi = {
  // 获取活动列表
  getActivityList(params) {
    return request.get("/api/activity/list", { params });
  },

  // 分页获取活动列表
  getActivityPage(params) {
    return request.get("/api/activity/page", { params });
  },

  // 获取活动详情
  getActivityById(id) {
    return request.get(`/api/activity/${id}`);
  },

  // 获取推荐活动
  getFeaturedActivities(params) {
    return request.get("/api/activity/featured", { params });
  },

  // 获取即将开始的活动
  getUpcomingActivities(params) {
    return request.get("/api/activity/upcoming", { params });
  },

  // 获取公开活动列表
  getPublicActivityList(params) {
    return request.get("/api/activity/public", { params });
  },

  // 报名参加活动
  registerActivity(activityId, registrationData) {
    return request.post(
      `/api/activity/${activityId}/register`,
      registrationData
    );
  },

  // 查询报名状态
  getRegistrationStatus(activityId, phone) {
    return request.get(`/api/activity/${activityId}/registration/status`, {
      params: { phone },
    });
  },

  // 分页获取公开活动列表
  getPublicActivityPage(params) {
    return request.get("/api/activity/public/page", { params });
  },

  // 报名活动列表
  getActivityTypes(phone) {
    return request.get("/api/activity/types", { params: { phone } });
  },
};

// 展商相关接口
export const exhibitorApi = {
  // 获取公开展商列表
  getPublicExhibitorList(params) {
    return request.get("/api/exhibitor/public", { params });
  },

  // 分页获取公开展商列表
  getPublicExhibitorPage(params) {
    return request.get("/api/exhibitor/public/page", { params });
  },

  // 获取展商详情
  getExhibitorById(id) {
    return request.get(`/api/exhibitor/${id}`);
  },

  // 获取展商产品列表
  getExhibitorProducts(id) {
    return request.get(`/api/exhibitor/${id}/products`);
  },

  // 获取展商名录（简化信息）
  getExhibitorDirectory(params) {
    return request.get("/api/exhibitor/directory", { params });
  },
};

// 产品相关接口
export const productApi = {
  // 分页获取所有展商产品列表（用户端）
  getPublicProductPage(params) {
    return request.get("/api/exhibitor/product/public/page", { params });
  },

  // 获取产品详情（用户端）
  getPublicProductById(id) {
    return request.get(`/api/exhibitor/product/public/${id}`);
  },

  // 根据展商ID获取产品列表（用户端）
  getPublicProductsByExhibitor(exhibitorId, params) {
    return request.get(
      `/api/exhibitor/product/public/exhibitor/${exhibitorId}`,
      { params }
    );
  },

  // 搜索产品（用户端）
  searchPublicProducts(params) {
    return request.get("/api/exhibitor/product/public/search", { params });
  },
};

// 观众相关接口
export const visitorApi = {
  // 观众注册
  register(data) {
    return request.post("/api/visitor/register", data);
  },

  // 观众预登记
  preRegister(data) {
    return request.post("/api/visitor/pre-register", data);
  },

  // 展商名录
  visitorRoster() {
    return request.get("/api/subpage/list/visitors/visitor-roster");
  },
};

// 组团参观（用户端）
export const groupVisitApi = {
  apply(data) {
    return request.post("/api/group-visit/apply", data);
  },
};

// 票务相关接口
export const ticketApi = {
  // 票务查询
  getTicketInfo(params) {
    return request.get("/api/ticket/info", { params });
  },

  // 购票
  buyTicket(data) {
    return request.post("/api/ticket/buy", data);
  },
};

// 签证相关接口
export const visaApi = {
  // 签证申请
  applyVisa(data) {
    return request.post("/api/visa/apply", data);
  },

  // 查询签证状态
  getVisaStatus(params) {
    return request.get("/api/visa/status", { params });
  },
};

// 展商申请相关接口
export const exhibitApi = {
  // 展商申请
  applyExhibit(data) {
    return request.post("/api/exhibit/apply", data);
  },

  // 展位预订
  bookBooth(data) {
    return request.post("/api/exhibit/book-booth", data);
  },
};

// 用户端-展商报名（直接创建待审核展商）
export const exhibitorRegistrationApi = {
  submit(data) {
    return request.post("/api/exhibitor/register", data);
  },
};

// 媒体相关接口
export const mediaApi = {
  // 媒体注册
  registerMedia(data) {
    return request.post("/api/media/register", data);
  },

  // 获取媒体资料
  getMediaResources(params) {
    return request.get("/api/media/resources", { params });
  },
};

// 下载相关接口
export const downloadApi = {
  // 获取下载文件列表
  getDownloadList(params) {
    return request.get("/api/download/list", { params });
  },

  // 下载文件
  downloadFile(id) {
    return request.get(`/api/download/file/${id}`);
  },
};

// 子页面相关API
export const subpageApi = {
  // 根据模块获取子页面列表
  getSubpagesByModule: (module) => request.get(`/api/subpage/module/${module}`),

  // 根据页面键和区块键获取子页面列表
  getSubpageList: (pageKey, sectionKey) =>
    request.get(`/api/subpage/list/${pageKey}/${sectionKey}`),

  // 根据页面键获取子页面内容
  getSubpageByKey: (pageKey, sectionKey) =>
    request.get(`/api/subpage/key/${pageKey}/${sectionKey}`),

  // 获取所有活跃的子页面
  getAllActiveSubpages: () => request.get("/api/subpage/all/active"),

  // 根据内容类型获取数据
  getContentByType: (contentType) =>
    request.get(`/api/homepage/content/${contentType}`),

  // 观众登记提交
  submitVisitorRegistration: (data) =>
    request.post("/api/registration/visitor", data),

  // 观众预登记提交
  submitVisitorPreregistration: (data) =>
    request.post("/api/registration/visitor-preregistration", data),

  // 参展报名提交
  submitExhibitRegistration: (data) =>
    request.post("/api/registration/exhibit", data),

  // 活动报名提交
  submitActivityRegistration: (data) =>
    request.post("/api/registration/activity", data),

  // 论坛报名提交
  submitForumRegistration: (data) =>
    request.post("/api/registration/forum", data),

  // 产品发布报名提交
  submitProductLaunchRegistration: (data) =>
    request.post("/api/registration/product-launch", data),

  // 媒体注册提交
  submitMediaRegistration: (data) =>
    request.post("/api/registration/media", data),
};

// 隐私政策接口
export const privacyApi = {
  // 获取底部服务条款
  getFooterTerms: () => request.get("/site/footer-terms-of-service"),
  // 获取底部隐私政策
  getFooterPrivacyPolicy: () => request.get("/site/footer-privacy-policy"),
  // 获取观众预登记页隐私政策
  getVisitorPrivacyPolicy: () => request.get("/site/visitor-privacy-policy"),
  // 获取观众预登记页参观条款
  getVisitorTerms: () => request.get("/site/visitor-terms"),
};
